<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<style>
.table-bordered,.table-bordered>thead>tr>th, .table-bordered>tbody>tr>th, .table-bordered>tfoot>tr>th, .table-bordered>thead>tr>td, .table-bordered>tbody>tr>td, .table-bordered>tfoot>tr>td{
    border: 1px solid #cdcdcd;
}
</style>
<div class="row">
    <div class="col-sm-12">
        <div class="box">
        <div class="box-header with-border">
       
        <h2 class="page-header">
        <div class="pull-right">   <a href="/backend/paypal/account" class="btn btn-sm btn-info btn-flat">返回列表</a> </div>
          <?php echo form_open(current_url(), array('class' => 'form-inline', 'method'=>'get','id' => 'f')); ?>
                <div class="form-group filtercol" id="filtertype1" style="margin-right:15px;">
                    <?php echo tpl_form_field_daterange("timelimit",$timerange,false);?>
                </div>
                <div class="form-group">
                    <div class="btn-group">
                        <?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-sm btn-primary btn-flat', 'content' => '查询')); ?>
                    </div>
                </div>
            <?php echo form_close();?>
           
        </h2>
        
        </div>
        <div class="box-body">
            <table id="example2" class="table table-bordered table-hover dataTable" role="grid" aria-describedby="example2_info">
                <thead>
                <tr role="row">
                    <th tabindex="0" aria-controls="example2" rowspan="1" colspan="1" >站点</th>
                    <th class="sorting" tabindex="1" aria-controls="example2" rowspan="1" colspan="1" aria-sort="ascending">使用次数</th>
                    <th class="sorting" tabindex="2" aria-controls="example2" rowspan="1" colspan="1" >支付金额</th>
                </tr>
                </thead>
                <tbody>
                
                <?php
                 $sum=[
                    "totalsum"=>0,
                    "totalamount"=>0,
                ];

                if($result):
                $rowcount=0;
                foreach($result as $item):
                    $sum["totalsum"]+=$item["totalcount"];
                    $sum["totalamount"]+=$item["totalamount"];
                ?>
                <tr role="row" class="<?php if($rowcount%2==0) echo "odd";else echo "even";?>">
                  <td class=""><div><?php echo $sites[$item["siteid"]]["name"];?></div>
                  <div style="color: rgba(0,0,0,.54);"><?php echo $sites[$item["siteid"]]["domian"];?></div></td>
                  <td class=""><?php echo $item["totalcount"];?></td>
                  <td class=""><?php echo $item["totalamount"];?></td>
                </tr>
                <?php
                $rowcount++;
                endforeach;

                endif;
                ?>
                </tbody>
                <tfoot>
                <tr><th rowspan="1" colspan="1">总计</th>
                <th rowspan="1" colspan="1"><?php echo $sum["totalsum"];?></th>
                <th rowspan="1" colspan="1"><?php echo $sum["totalamount"];?></th>
              
                </tr>
                </tfoot>
              </table>

        </div>
    </div>
</div>
<link rel="stylesheet" href="/assets/backend/jquery.dataTables.min.css">
<script type="text/javascript" src="/assets/backend/jquery.dataTables.min.js"></script>
<script>
  $(function () {
    $('#example2').DataTable({
      'paging'      : false,
      'lengthChange': false,
      'searching'   : false,
      'ordering'    : true,
      'info'        : false,
      'autoWidth'   : true,
      "columns": [
            { "orderable": false },
            null,
            null,
        ],

    });
    $("thead th:eq(1)").click().click();
  })
</script>
